using AspectCore.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using System.Globalization;

namespace JNPF.Api
{
    /// <summary>
    /// 
    /// </summary>
    public class Program
    {
        /// <summary>
        /// Main
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("zh-CN", true)
            {
                DateTimeFormat =
                {
                    ShortDatePattern="yyyy-MM-dd",
                    ShortTimePattern = "HH:mm:ss",
                    FullDateTimePattern = "yyyy-MM-dd HH:mm:ss",
                    LongDatePattern = "yyyy-MM-dd",
                    LongTimePattern = "HH:mm:ss"
                }
            };
            CreateHostBuilder(args).Build().Run();
        }
        /// <summary>
        /// CreateWebHostBuilder
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder =>
            { 
                webBuilder.UseUrls("http://*:4002").UseStartup<Startup>();
            })
            //用AspectCore替换默认的IOC容器
            .UseServiceProviderFactory(new DynamicProxyServiceProviderFactory());
    }
}
